package com.seuic.hnapps.project;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.orhanobut.logger.Logger;
import com.seuic.hnapps.BaseActivity;
import com.seuic.hnapps.R;
import com.seuic.hnapps.SquareLayout;
import com.seuic.hnapps.adapter.Dq_adapter;
import com.seuic.hnapps.adapter.InTrates_adapter;
import com.seuic.hnapps.adapter.Mx_adapter;
import com.seuic.hnapps.adapter.Select_subaccount_adapter;
import com.seuic.hnapps.bean.CardBinInfo_bean;
import com.seuic.hnapps.bean.DQ_Bean;
import com.seuic.hnapps.bean.InTrates_Bean;
import com.seuic.hnapps.bean.K_binBean;
import com.seuic.hnapps.bean.Mx_Bean;
import com.seuic.hnapps.bean.Select_subaccount_Bean;
import com.seuic.hnapps.constants.EmvConstants;
import com.seuic.hnapps.posdsdk.pos_func.PosCallbacks;
import com.seuic.hnapps.posdsdk.pos_func.PosFuncs;
import com.seuic.hnapps.util.BLAInterface;
import com.seuic.hnapps.util.CommAdapter;
import com.seuic.hnapps.util.Constants;
import com.seuic.hnapps.util.DQMInterface;
import com.seuic.hnapps.util.LLInstall;
import com.seuic.hnapps.util.PinPad;
import com.seuic.hnapps.util.QMXInterface;
import com.seuic.hnapps.util.SBAInterface;
import com.seuic.hnapps.util.ServiceCommon;
import com.seuic.hnapps.util.SpUtils;
import com.seuic.hnapps.util.Utils;
import com.seuic.hnapps.util.VTAInterface;
import com.solab.enc.DES3;
import com.solab.enc.HexT;
import com.solab.enc.SMS4;
import com.solab.iso8583.IsoMessage;
import com.solab.iso8583.MessageFactory;

import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * isjingkai
 * 2019年7月20日11:00:15
 * 查询业务
 */
public class InquiryBusinessActivity extends BaseActivity {
    Runnable runnable;
    Handler handler;
    PosFuncs posFuncs;
    String bindNum;
    String pass_word;
    String CardType;
    SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
    Calendar c = Calendar.getInstance();


    @BindView(R.id.base_back_btn)
    LinearLayout baseBackBtn;
    @BindView(R.id.base_title_text)
    TextView baseTitleText;
    @BindView(R.id.query_balance_btn)
    SquareLayout queryBalanceBtn;
    @BindView(R.id.query_interestrate_btn)
    SquareLayout queryInterestrateBtn;
    @BindView(R.id.query_son_btn)
    SquareLayout querySonBtn;
    @BindView(R.id.query_dueondemand_btn)
    SquareLayout queryDueondemandBtn;
    @BindView(R.id.query_atfixedperiod_btn)
    SquareLayout queryAtfixedperiodBtn;
    @BindView(R.id.home_query_layout)
    CardView homeQueryLayout;
    @BindView(R.id.inquiry_business_home_layout)
    LinearLayout inquiryBusinessHomeLayout;
    @BindView(R.id.dealing_layout)
    LinearLayout dealingLayout;
    @BindView(R.id.account_balance)
    TextView accountBalance;
    @BindView(R.id.usable_balance)
    TextView usableBalance;
    @BindView(R.id.query_success_btn)
    Button querySuccessBtn;
    @BindView(R.id.query_success_layout)
    LinearLayout querySuccessLayout;
    @BindView(R.id.interest_rates_query_okbtn)
    Button interestRatesQueryOkbtn;
    @BindView(R.id.interest_rates_query_layout)
    CardView interestRatesQueryLayout;
    //    @BindView(R.id.please_input_iccard_okbtn)
//    Button pleaseInputIccardOkbtn;
    @BindView(R.id.please_input_iccard_layout)
    LinearLayout pleaseInputIccardLayout;
    @BindView(R.id.ficationing_layout)
    LinearLayout ficationingLayout;
    @BindView(R.id.query_sun_recyclerview)
    RecyclerView querySunRecyclerview;
    @BindView(R.id.query_sun_layout)
    CardView querySunLayout;
    @BindView(R.id.query_sun_nobtn)
    Button querySunNobtn;
    @BindView(R.id.query_sun_okbtn)
    Button querySunOkbtn;
    @BindView(R.id.sure_printingpeper_okbtn)
    Button surePrintingpeperOkbtn;
    @BindView(R.id.sure_printingpeper_layout)
    LinearLayout surePrintingpeperLayout;
    @BindView(R.id.printing_layout)
    LinearLayout printingLayout;
    @BindView(R.id.detail_query_recyclerview)
    RecyclerView detailQueryRecyclerview;
    @BindView(R.id.detail_query_nobtn)
    Button detailQueryNobtn;
    @BindView(R.id.detail_query_okbtn)
    Button detailQueryOkbtn;
    @BindView(R.id.detail_query_layout)
    CardView detailQueryLayout;
    @BindView(R.id.detail_query_title)
    TextView detailQueryTitle;
    @BindView(R.id.select_detail_type_lm)
    Button selectDetailTypeLm;
    @BindView(R.id.select_detail_type_3m)
    Button selectDetailType3m;
    @BindView(R.id.select_detail_type_custom)
    Button selectDetailTypeCustom;
    @BindView(R.id.select_detail_type_layout)
    LinearLayout selectDetailTypeLayout;
    @BindView(R.id.custom_detail_time_starttime)
    EditText customDetailTimeStarttime;
    @BindView(R.id.custom_detail_time_stoptime)
    EditText customDetailTimeStoptime;
    @BindView(R.id.custom_detail_time_nobtn)
    Button customDetailTimeNobtn;
    @BindView(R.id.custom_detail_time_okbtn)
    Button customDetailTimeOkbtn;
    @BindView(R.id.custom_detail_time_layout)
    LinearLayout customDetailTimeLayout;
    @BindView(R.id.interest_rates_recyclerview)
    RecyclerView interestRatesRecyclerview;
    @BindView(R.id.th_okbtn)
    Button thOkbtn;
    @BindView(R.id.th_layout)
    LinearLayout thLayout;
    private String field55;
    private int num;
    private String time;
    private String track2Data;
    private String track3Data;
    private String s_number;
    private String kyye;
    private String zhye;
    private String make_type = "";
    private String mon3;
    private String mon;
    private boolean f59;
    private String f59data = "";
    private int qingqiu_num = 0;
    private Mx_adapter adapter_mx;
    private List<Mx_Bean> beans;
    private List<Select_subaccount_Bean> beans_zzh;
    private boolean f59_zzhcx;
    private String f59data_zzhcx;
    private Select_subaccount_adapter adapter_zzhcx;
    private int qqzzhcx_num;
    private List<DQ_Bean> beans_dq;
    private int dqqq_num = 0;
    private Dq_adapter dq_adapter;
    private boolean f59_dq;
    private String f59_dqdata;
    private String type;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_inquiry_business);
        ButterKnife.bind(this);
        this.setBackBtClick(R.id.base_back_btn);
        this.setTitleText(R.id.base_title_text, "(   " + "查询业务" + "   )");
        handler = new Handler();
        posFuncs = PosFuncs.getInstace();
        posFuncs.init(this);
    }

    @OnClick({R.id.query_balance_btn, R.id.query_interestrate_btn,
            R.id.query_son_btn, R.id.query_dueondemand_btn,
            R.id.query_atfixedperiod_btn, R.id.query_success_btn,
            R.id.interest_rates_query_okbtn,
//            R.id.please_input_iccard_okbtn,
            R.id.query_sun_nobtn, R.id.query_sun_okbtn,
            R.id.sure_printingpeper_okbtn, R.id.detail_query_nobtn,
            R.id.detail_query_okbtn, R.id.select_detail_type_lm,
            R.id.select_detail_type_3m, R.id.select_detail_type_custom,
            R.id.custom_detail_time_nobtn, R.id.custom_detail_time_okbtn, R.id.th_okbtn
    })
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.query_balance_btn:
                //余额查询
                inquiryBusinessHomeLayout.setVisibility(View.GONE);
                dealingLayout.setVisibility(View.VISIBLE);
                make_type = "yecx";
                tradeWithCards(0.00);
//                readCardTest();
//                runnable = new Runnable() {
//                    @Override
//                    public void run() {
//                        dealingLayout.setVisibility(View.GONE);
//                        querySuccessLayout.setVisibility(View.VISIBLE);
//                    }
//                };
//                handler.postDelayed(runnable, 1000);
                break;
            case R.id.query_interestrate_btn:
                //利率查询
//                Toast.makeText(this, "该功能尚未开通,敬请期待", Toast.LENGTH_SHORT).show();

                homeQueryLayout.setVisibility(View.GONE);
                interestRatesQueryLayout.setVisibility(View.VISIBLE);
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        Logger.e("s_number" + s_number);
                        int Num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1);
                        Logger.e("第一次获取rz" + Num);
                        LLInstall(String.valueOf(Num));
                        SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", Num + 1);
                        Logger.e("第二次获取rz" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1));
                    }
                }).start();
                break;
            case R.id.query_son_btn:
                //子账户查询
//                Toast.makeText(this, "该功能尚未开通,敬请期待", Toast.LENGTH_SHORT).show();

                inquiryBusinessHomeLayout.setVisibility(View.GONE);
                pleaseInputIccardLayout.setVisibility(View.VISIBLE);
                make_type = "zzhcx";
                tradeWithCards(0);
                break;
            case R.id.query_dueondemand_btn:
                //活期明细查询
                inquiryBusinessHomeLayout.setVisibility(View.GONE);
                selectDetailTypeLayout.setVisibility(View.VISIBLE);

                break;
            case R.id.query_atfixedperiod_btn:
                Toast.makeText(this, "该功能尚未开通,敬请期待", Toast.LENGTH_SHORT).show();

//                //定期明细查询
//                inquiryBusinessHomeLayout.setVisibility(View.GONE);
//                customDetailTimeLayout.setVisibility(View.VISIBLE);
//                make_type = "dqmx";
//                ficationingLayout.setVisibility(View.VISIBLE);
//                runnable = new Runnable() {
//                    @Override
//                    public void run() {
//                        ficationingLayout.setVisibility(View.GONE);
//                        dealingLayout.setVisibility(View.VISIBLE);
//                        runnable = new Runnable() {
//                            @Override
//                            public void run() {
//                                homeQueryLayout.setVisibility(View.GONE);
//                                dealingLayout.setVisibility(View.GONE);
//                                detailQueryTitle.setText("定期存款账户交易明细");
////                                initRecyclerView();
//                                detailQueryLayout.setVisibility(View.VISIBLE);
//                            }
//                        };
//                        handler.postDelayed(runnable, 1000);
//                    }
//                };
//                handler.postDelayed(runnable, 1000);
                break;
            case R.id.query_success_btn:
                //查询成功 确认
                this.finish();
//                querySuccessLayout.setVisibility(View.GONE);
//                inquiryBusinessHomeLayout.setVisibility(View.VISIBLE);
                break;
            case R.id.interest_rates_query_okbtn:
                //利率查询 确认
                interestRatesQueryLayout.setVisibility(View.GONE);
                homeQueryLayout.setVisibility(View.VISIBLE);

                break;
//            case R.id.please_input_iccard_okbtn:
//                //确认插入卡
//                pleaseInputIccardLayout.setVisibility(View.GONE);
//                ficationingLayout.setVisibility(View.VISIBLE);
//                runnable = new Runnable() {
//                    @Override
//                    public void run() {
//                        ficationingLayout.setVisibility(View.GONE);
//                        dealingLayout.setVisibility(View.VISIBLE);
//                        runnable = new Runnable() {
//                            @Override
//                            public void run() {
//                                homeQueryLayout.setVisibility(View.GONE);
//                                dealingLayout.setVisibility(View.GONE);
//                                initRecyclerView();
//                                querySunLayout.setVisibility(View.VISIBLE);
//                            }
//                        };
//                        handler.postDelayed(runnable, 1000);
//                    }
//                };
//                handler.postDelayed(runnable, 1000);
//                break;
            case R.id.query_sun_nobtn:
                //查询子账户 取消
                this.finish();
                break;
            case R.id.query_sun_okbtn:
                //查询子账户 打印明细

                querySunLayout.setVisibility(View.GONE);
                homeQueryLayout.setVisibility(View.VISIBLE);
                surePrintingpeperLayout.setVisibility(View.VISIBLE);
                break;
            case R.id.sure_printingpeper_okbtn:
                //确认打印纸安装
                this.finish();
//                surePrintingpeperLayout.setVisibility(View.GONE);
//                printingLayout.setVisibility(View.VISIBLE);
//                runnable = new Runnable() {
//                    @Override
//                    public void run() {
//                        printingLayout.setVisibility(View.GONE);
//                        inquiryBusinessHomeLayout.setVisibility(View.VISIBLE);
//                    }
//                };
//                handler.postDelayed(runnable, 1000);
                break;
            case R.id.detail_query_nobtn:
                this.finish();
                //查询明细 取消
                break;
            case R.id.detail_query_okbtn:
                //查询明细 打印明细
                this.finish();
//                detailQueryLayout.setVisibility(View.GONE);
//                homeQueryLayout.setVisibility(View.VISIBLE);
//                surePrintingpeperLayout.setVisibility(View.VISIBLE);
                break;
            case R.id.select_detail_type_lm:
                make_type = "selectDetailType1";
                //一个月


                //过去一月
                c.setTime(new Date());
                c.add(Calendar.MONTH, -1);
                Date m = c.getTime();
                mon = format.format(m);
                System.out.println("过去一个月：" + mon);

                readCardTest();

                selectDetailTypeLayout.setVisibility(View.GONE);
                pleaseInputIccardLayout.setVisibility(View.VISIBLE);

                break;
            case R.id.select_detail_type_3m:
                make_type = "selectDetailType3";
                //三个月
                //过去三个月
                c.setTime(new Date());
                c.add(Calendar.MONTH, -3);
                Date m3 = c.getTime();
                mon3 = format.format(m3);
                System.out.println("过去三个月：" + mon3);

                readCardTest();

                selectDetailTypeLayout.setVisibility(View.GONE);
                pleaseInputIccardLayout.setVisibility(View.VISIBLE);
                break;
            case R.id.select_detail_type_custom:
                //自定义明细
                selectDetailTypeLayout.setVisibility(View.GONE);
                customDetailTimeLayout.setVisibility(View.VISIBLE);
                break;
            case R.id.custom_detail_time_nobtn:
                //自定义明细 取消
                this.finish();
                break;
            case R.id.custom_detail_time_okbtn:
                //自定义明细 确定
                if (customDetailTimeStarttime.getText().toString().equals("") &&
                        customDetailTimeStoptime.getText().toString().equals("")) {
                    Toast.makeText(this, "请输入日期", Toast.LENGTH_SHORT).show();

                } else {
                    if (customDetailTimeStarttime.getText().toString().length() != 8 && customDetailTimeStoptime.getText().toString().length() != 8) {
                        Toast.makeText(this, "请输入正确的日期", Toast.LENGTH_SHORT).show();
                    } else {
                        if (make_type.equals("dqmx")) {
                            tradeWithCards(0);
                            customDetailTimeLayout.setVisibility(View.GONE);
                            customDetailTimeOkbtn.setClickable(false);
                            dealingLayout.setVisibility(View.VISIBLE);
                        } else {
                            customDetailTimeLayout.setVisibility(View.GONE);
                            make_type = "customDetailType";
                            readCardTest();
                            selectDetailTypeLayout.setVisibility(View.GONE);
                            pleaseInputIccardLayout.setVisibility(View.VISIBLE);
                        }

                    }
                }
//                    customDetailTimeLayout.setVisibility(View.GONE);
//                    ficationingLayout.setVisibility(View.VISIBLE);
//                    runnable = new Runnable() {
//                        @Override
//                        public void run() {
//                            ficationingLayout.setVisibility(View.GONE);
//                            dealingLayout.setVisibility(View.VISIBLE);
//                            runnable = new Runnable() {
//                                @Override
//                                public void run() {
//                                    homeQueryLayout.setVisibility(View.GONE);
//                                    dealingLayout.setVisibility(View.GONE);
//                                    detailQueryTitle.setText("活期存款账户交易明细");
//                                    initRecyclerView();
//                                    detailQueryLayout.setVisibility(View.VISIBLE);
//                                }
//                            };
//                            handler.postDelayed(runnable, 1000);
//                        }
//                    };
//                    handler.postDelayed(runnable, 1000);

                break;
            case R.id.th_okbtn:
                thLayout.setVisibility(View.GONE);
                dealingLayout.setVisibility(View.VISIBLE);
                tradeWithCards(0.00);
                break;
        }
    }


    /**
     * 读取卡
     */
    private void readCardTest() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                posFuncs.cardReaderConfig(true, true, true);

                posFuncs.emvSimpleFlow(new PosCallbacks.EmvTransStartCallbacks() {
                    @Override
                    public void onDetectCard(String type) {
                        CardType = type;
                        Log.e("", type);
                    }

                    @Override
                    public void onConfirmCardInfo(String pan) {
                        Log.e("", pan);
                        bindNum = pan;
                        Toast.makeText(getApplicationContext(), pan, Toast.LENGTH_SHORT).show();
                        posFuncs.emvConfirmCardInfo(EmvConstants.CONFIRM_OK);

                    }

                    @Override
                    public void onOlinePinEntered(String enc, boolean is_no_pin) {

                    }

                    @Override
                    public void onSuccess(Bundle data) {
                        if (!data.isEmpty()) {


                            Logger.e("", data.getString(EmvConstants.FEILD_55));
                            //如果是磁条卡，就获取二磁信息、上传给银行接口
                            // IC Card    MAG Card    RF Card
                            if (CardType.equals("MAG Card")) {
                                track2Data = data.getString(EmvConstants.TRACK2);
                                track3Data = data.getString(EmvConstants.TRACK3);
                                Logger.e("MAG Card");
                            } else {
                                Logger.e("ic Card");
                                track2Data = Utils.formatField57(Utils.getValueFromIccData("57", data.getString(EmvConstants.FEILD_55)));
                                s_number = Utils.getValueFromIccData("5f34", data.getString(EmvConstants.FEILD_55));
                                String[] tags =
                                        {
                                                "9F26", "9F27", "9F10", "9F37", "9F36", "95",
                                                "9A", "9C", "9F02", "5F2A", "82", "9F1A", "9F03", "9F33", "9F34", "9F35",
                                                "9F1E", "84", "9F09", "9F41"
                                        };
                                field55 = Utils.getField55(tags, data.getString(EmvConstants.FEILD_55));
                                Logger.e(s_number + "s_numbers_number");
                            }
//                            String k_bind = SpUtils.getSPUtil(getApplicationContext()).getString("k_bean", "");
//
//                            Gson gson = new Gson();
//                            List<K_binBean> beans = gson.fromJson(k_bind, new TypeToken<List<K_binBean>>() {
//                            }.getType());
//                            Logger.e(beans.size() + "beans.size()");
//                            for (int i = 0; i < beans.size(); i++) {
//                                String lenght = beans.get(i).getK_lenght().substring(1);
//                                String this_kind = bindNum.substring(0, Integer.valueOf(lenght));
//                                if (beans.get(i).getK_bin().equals(this_kind)) {
//                                    type = "bh";
//                                    break;
//                                } else {
//                                    //
//                                    if (i == beans.size() - 1) {
//                                        type = "th";
//                                        Logger.e("他行卡");
//                                        Toast.makeText(InquiryBusinessActivity.this, "他行卡", Toast.LENGTH_SHORT).show();
////                                    pleasewycLayout.setVisibility(View.GONE);
////                                    importMoneynumLayout.setVisibility(View.VISIBLE);
//                                        dealingLayout.setVisibility(View.GONE);
//                                        thLayout.setVisibility(View.VISIBLE);
//                                        break;
//                                    } else {
//                                        continue;
//                                    }
//
//                                }
//                            }
//                            if (type.equals("bh")) {
                            pleaseInputIccardLayout.setVisibility(View.GONE);
                            ficationingLayout.setVisibility(View.VISIBLE);
//                                Toast.makeText(InquiryBusinessActivity.this, "本行卡", Toast.LENGTH_SHORT).show();
                            Logger.e("本行卡");
//                                pleasewycLayout.setVisibility(View.GONE);
//                                verificationingLayout.setVisibility(View.VISIBLE);
                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    Logger.e("s_number" + s_number);
                                    int Num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1);
                                    Logger.e("第一次获取rz" + Num);
                                    excuteVTA(String.valueOf(Num), bindNum, CardType, track2Data, s_number);
                                    SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", Num + 1);
                                    Logger.e("第二次获取rz" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1));
                                }
                            }).start();
//                            } else {
//
//                            }


                        }


                    }

                    @Override
                    public void onFailed(String error) {
                        Logger.e(error);
                        Toast.makeText(InquiryBusinessActivity.this, "请插入卡", Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }).start();


    }


    /**
     * 调取键盘
     */
    private void enterPin(final String bindNum, final double money) {
        Logger.e(money + "");
        new Thread() {
            @Override
            public void run() {
                posFuncs.enterPin(new PosCallbacks.EnterPinCallbacks() {
                    @Override
                    public void onSuccess(final String enc, boolean is_no_pin) {
                        if (is_no_pin) {
                        } else {
                            Log.e("", enc);
                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                                    Logger.e("第一次获取" + num);
//                                    excuteVTA(String.valueOf(num), bindNum, track2Data, track3Data, importMoneynumEdtext.getText().toString(), enc, CardType, Field55);
                                    SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                                    Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));

                                }
                            }).start();

                        }
                    }

                    @Override
                    public void onFail(String error) {
                        Toast.makeText(InquiryBusinessActivity.this, "交易结束", Toast.LENGTH_SHORT).show();
                        if (!error.equals(null)) {
                            finish();
                        }

                    }

                    @Override
                    public void onInput(int input_num) {
                        Log.e("", String.valueOf(input_num));
                    }
                }, bindNum, (int) money);
            }
        }.start();
    }

    private void tradeWithCards(final double money) {
        PinPad.initPinPad(posFuncs);
        new Thread() {
            @Override
            public void run() {

                posFuncs.cardReaderConfig(true, true, true);
                posFuncs.emvTransStart(new PosCallbacks.EmvTransStartCallbacks() {

                    @Override
                    public void onDetectCard(String type) {
                        CardType = type;
                    }

                    @Override
                    public void onConfirmCardInfo(final String pan) {
                        bindNum = pan;
                        posFuncs.emvConfirmCardInfo(EmvConstants.CONFIRM_OK);

                    }

                    @Override
                    public void onOlinePinEntered(String enc, boolean is_no_pin) {
                        if (!is_no_pin) {

                            try {
                                String pin = PinPad.getPin(bindNum, enc);
                                pass_word = pin;
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }

                    @Override
                    public void onSuccess(Bundle data) {
                        String channel = data.getString(EmvConstants.CHANNEL);
                        if (EmvConstants.CHANNEL_MAGCARD.equals(channel)) {
//                            appendInfo("MagCard Used\n");
//                            appendInfo("Track1: " + data.getString(EmvConstants.TRACK1) + "\n");
//                            appendInfo("Track2: " + data.getString(EmvConstants.TRACK2) + "\n");
//                            appendInfo("Track3: " + data.getString(EmvConstants.TRACK3) + "\n");
//                            appendInfo("\nFinish\n");
//                            setEmvProcessStatus(false);
                        } else if (EmvConstants.CHANNEL_ICC.equals(channel)) {
//                            appendInfo("ICCard Used\n");
                            track2Data = Utils.formatField57(Utils.getValueFromIccData("57", data.getString(EmvConstants.FEILD_55)));
                            s_number = Utils.getValueFromIccData("5f34", data.getString(EmvConstants.FEILD_55));
                            String ac_type = data.getString(EmvConstants.AC_TYPE);
                            Logger.e("ac_type" + ac_type);
                            Logger.e("Ac Type: " + data.getString(EmvConstants.AC_TYPE) + "\n");
                            Logger.e("Field 55: " + data.getString(EmvConstants.FEILD_55) + "\n");
                            String[] tags =
                                    {
                                            "9F26", "9F27", "9F10", "9F37", "9F36", "95",
                                            "9A", "9C", "9F02", "5F2A", "82", "9F1A", "9F03", "9F33", "9F34", "9F35",
                                            "9F1E", "84", "9F09", "9F41"
                                    };
                            field55 = Utils.getField55(tags, data.getString(EmvConstants.FEILD_55));
                            Logger.e("f55" + field55);
                            if (EmvConstants.AC_TYPE_ARQC.equals(ac_type)) {

                                Bundle bundle = new Bundle();
                                bundle.putString(EmvConstants.RESPONSE_CODE, "3030");
                                posFuncs.emvOnlineResult(new PosCallbacks.EmvOnlineResultCallbacks() {
                                    @Override
                                    public void onSuccess(Bundle data) {
                                        Logger.e("Ac Type: " + data.getString(EmvConstants.AC_TYPE) + "\n");
                                        Logger.e("Field 55: " + data.getString(EmvConstants.FEILD_55) + "\n");

                                    }

                                    @Override
                                    public void onFailed(String error) {

                                    }
                                }, bundle);
                            } else {

                            }
                        } else if (EmvConstants.CHANNEL_ICCL.equals(channel)) {
                            Logger.e("Ac Type: " + data.getString(EmvConstants.AC_TYPE) + "\n");
                            Logger.e("Field 55: " + data.getString(EmvConstants.FEILD_55) + "\n");

                        }
                        new Thread(new Runnable() {
                            @Override
                            public void run() {
                                if (make_type.equals("selectDetailType1")) {
                                    num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                                    Logger.e("第一次获取" + num);
                                    excuteQMX(String.valueOf(num), bindNum, track2Data);
                                    SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                                    Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
                                } else if (make_type.equals("selectDetailType3")) {
                                    num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                                    Logger.e("第一次获取" + num);
                                    excuteQMX3(String.valueOf(num), bindNum, track2Data);
                                    SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                                    Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
                                } else if (make_type.equals("customDetailType")) {
                                    num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                                    Logger.e("第一次获取" + num);
                                    excuteQMXcustom(String.valueOf(num), bindNum, track2Data);
                                    SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                                    Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));

                                } else if (make_type.equals("zzhcx")) {
                                    num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                                    Logger.e("第一次获取" + num);
                                    excuteVTA(String.valueOf(num), bindNum, CardType, track2Data, s_number);
                                    SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                                    Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));

                                } else if (make_type.equals("yecx")) {
                                    num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                                    Logger.e("第一次获取" + num);
                                    excute(String.valueOf(num), bindNum, track2Data);
                                    SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                                    Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
                                } else if (make_type.equals("dqmx")) {
                                    num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                                    Logger.e("第一次获取" + num);
                                    excuteVTA(String.valueOf(num), bindNum, CardType, track2Data, s_number);
                                    SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                                    Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));

                                }
                            }
                        }).start();
                    }

                    @Override
                    public void onFailed(String error) {

                    }
                }, (int) money, 0);
            }
        }.start();
    }

    private void excuteQMX(String transn, String bindNum, String track2Data) {
        String c_bin_info = SpUtils.getSPUtil(getApplicationContext()).getString("c_bin_info", "null");
        Gson gson = new Gson();
        List<CardBinInfo_bean> beans = gson.fromJson(c_bin_info, new TypeToken<List<CardBinInfo_bean>>() {
        }.getType());
        IsoMessage msg = null;
        QMXInterface inter = new QMXInterface();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");// HH:mm:ss
        //获取当前时间
        Date date = new Date(System.currentTimeMillis());
        Logger.e("Date获取当前日期时间" + simpleDateFormat.format(date).replace("/", ""));
        msg = inter.packRequest(bindNum, transn, beans, CardType, track2Data, track3Data, "1", s_number, pass_word, field55, mon.replace("/", ""), simpleDateFormat.format(date).replace("/", ""), qingqiu_num, f59data);
        excuteRequest(msg, "hq_mxcx1");
    }

    private void excuteQMX3(String transn, String bindNum, String track2Data) {
        String c_bin_info = SpUtils.getSPUtil(getApplicationContext()).getString("c_bin_info", "null");
        Gson gson = new Gson();
        List<CardBinInfo_bean> beans = gson.fromJson(c_bin_info, new TypeToken<List<CardBinInfo_bean>>() {
        }.getType());
        Logger.e(beans.size() + "beans.size()");
        IsoMessage msg = null;
        QMXInterface inter = new QMXInterface();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");// HH:mm:ss
        //获取当前时间
        Date date = new Date(System.currentTimeMillis());
        Logger.e("Date获取当前日期时间" + simpleDateFormat.format(date).replace("/", ""));
        msg = inter.packRequest(bindNum, transn, beans, CardType, track2Data, track3Data, "1", s_number, pass_word, field55, mon3.replace("/", ""), simpleDateFormat.format(date).replace("/", ""), qingqiu_num, f59data);
        excuteRequest(msg, "hq_mxcx3");
    }

    private void excuteQMXcustom(String transn, String bindNum, String track2Data) {
        String c_bin_info = SpUtils.getSPUtil(getApplicationContext()).getString("c_bin_info", "null");
        Gson gson = new Gson();
        List<CardBinInfo_bean> beans = gson.fromJson(c_bin_info, new TypeToken<List<CardBinInfo_bean>>() {
        }.getType());
        Logger.e(beans.size() + "beans.size()");
        IsoMessage msg = null;
        QMXInterface inter = new QMXInterface();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd");// HH:mm:ss
        //获取当前时间
        Date date = new Date(System.currentTimeMillis());
        Logger.e("Date获取当前日期时间" + simpleDateFormat.format(date).replace("/", ""));
        msg = inter.packRequest(bindNum, transn, beans, CardType, track2Data, track3Data, "1", s_number, pass_word, field55, customDetailTimeStarttime.getText().toString(), customDetailTimeStoptime.getText().toString(), qingqiu_num, f59data);
        excuteRequest(msg, "hq_cuastomdata");
    }


    /**
     * 账户验证
     */
    public void excuteVTA(String transn, String bindNum, String CardTYpe, String track2Data, String s_number) {
        String c_bin_info = SpUtils.getSPUtil(getApplicationContext()).getString("c_bin_info", "null");
        Gson gson = new Gson();
        List<CardBinInfo_bean> beans = gson.fromJson(c_bin_info, new TypeToken<List<CardBinInfo_bean>>() {
        }.getType());
        Logger.e(beans.size() + "beans.size()");
        IsoMessage msg = null;
        VTAInterface inter = new VTAInterface();
        msg = inter.packRequest(bindNum, beans, transn, track2Data, CardTYpe, String.valueOf(2), s_number);
        excuteRequest(msg, "zhrz");
    }

    /**
     * 利率查询
     */
    public void LLInstall(String transn) {

        IsoMessage msg = null;
        LLInstall inter = new LLInstall();
        msg = inter.packRequest(transn);
        excuteRequest(msg, "llcx");
    }

    /**
     * 定期明细查询
     */
    public void DQMInstall(String transn) {
        String c_bin_info = SpUtils.getSPUtil(getApplicationContext()).getString("c_bin_info", "null");
        Gson gson = new Gson();
        List<CardBinInfo_bean> beans = gson.fromJson(c_bin_info, new TypeToken<List<CardBinInfo_bean>>() {

        }.getType());
        IsoMessage msg = null;
        DQMInterface inter = new DQMInterface();
        msg = inter.packRequest(bindNum, beans, transn, track2Data, track3Data, pass_word, CardType, String.valueOf(1), field55, s_number, dqqq_num, f59_dqdata, customDetailTimeStarttime.getText().toString().trim(), customDetailTimeStoptime.getText().toString().trim());
        excuteRequest(msg, "dqmx");
    }

    /**
     * 子账户查询
     */
    public void excuteSBA(String transn, String CardType) {
        String c_bin_info = SpUtils.getSPUtil(getApplicationContext()).getString("c_bin_info", "null");
        Gson gson = new Gson();
        List<CardBinInfo_bean> beans = gson.fromJson(c_bin_info, new TypeToken<List<CardBinInfo_bean>>() {
        }.getType());
        IsoMessage msg = null;
        SBAInterface inter = new SBAInterface();
        msg = inter.packRequest(bindNum, beans, transn, track2Data, track3Data, pass_word, CardType, String.valueOf(1), field55, s_number, qqzzhcx_num, f59data_zzhcx);
        excuteRequest(msg, "zzhcx");
    }

    /**
     * 余额查询
     */
    public void excute(String transn, String bindNum, String track2Data) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");// HH:mm:ss

        Date date = new Date(System.currentTimeMillis());
        time = simpleDateFormat.format(date);
        String c_bin_info = SpUtils.getSPUtil(getApplicationContext()).getString("c_bin_info", "null");
        Gson gson = new Gson();
        List<CardBinInfo_bean> beans = gson.fromJson(c_bin_info, new TypeToken<List<CardBinInfo_bean>>() {
        }.getType());
        Logger.e(beans.size() + "beans.size()");
        IsoMessage msg = null;
        BLAInterface inter = new BLAInterface();

        msg = inter.packRequest(type, bindNum, beans, transn, track2Data, CardType, "1", s_number, field55, pass_word);

        excuteRequest(msg, "yecx");
    }


    private void excuteRequest(IsoMessage msg, final String op_type) {

        byte[] data = msg.writeData();
        // ��д����ͷ��7�򳤶�ֵ
        int hlen = Constants.ATMP_HEADER_LENGTH;
        int bodylen = data.length - hlen;
        String headF7 = ServiceCommon.appendZero(bodylen, 4);
        System.arraycopy(headF7.getBytes(), 0, data, 28, 4);
        // ����MAC
        if (msg.getField(128) != null) {
//            int start = hlen;
//            int length = data.length - start - 8;
//            byte[] inmac = new byte[length];
//            byte[] outmac = new byte[16];
//            System.arraycopy(data, start, inmac, 0, length);
//            Logger.e("MAC����=[{}]" + HexT.byteArr2HexStr(inmac));
//            Logger.e(Constants.YANTAI_MACKEY);
//            String mackey = Constants.YANTAI_MACKEY;
//            // MAC99�㷨makֻ��Ҫ16�ֽ���Կ
//            if (mackey.length() > 16) {
//                mackey = mackey.substring(0, 16);
//            }
//            DES3.getMacBlock_99(inmac, mackey.getBytes(), outmac);
//            System.arraycopy(outmac, 0, data, data.length - 8, 8);
//            Logger.e("����MAC=[{}]" + new String(outmac).substring(0, 8));
            int start = hlen;
            int length = data.length - start - 8;
            byte[] inmac = new byte[length];
            byte[] outmac = new byte[16];
            System.arraycopy(data, start, inmac, 0, length);
            System.out.println("MAC数据=[" + HexT.byteArr2HexStr(inmac) + "]");
            String mackey = Constants.YANTAI_MACKEY;

            if (Constants.isSM) {
                // SM4 MAC919算法
                byte[] mkey = HexT.hexstr2ByteArr(mackey);
                String macval = SMS4.sms4MacBlock_919(inmac, mkey);
                outmac = macval.getBytes();
            } else {
                // MAC99算法mak只需要16字节密钥
                if (mackey.length() > 16) {
                    mackey = mackey.substring(0, 16);
                }
                DES3.getMacBlock_99(inmac, mackey.getBytes(), outmac);
            }

            System.arraycopy(outmac, 0, data, data.length - 8, 8);
            System.out.println("请求MAC=[" + new String(outmac).substring(0, 8) + "]");
        }
        byte[] send = null;
        // ���ļ��ܣ���������ʱ��ҵ���ױ��뱨�ļ���
        String encflag = msg.getHeadStringValue(4);
        if ("1".equals(encflag)) {
            String tdk = Constants.YANTAI_TDKKEY;
            int lenr = 8 - bodylen % 8;
            byte[] head = new byte[hlen];
            byte[] decdata = new byte[bodylen + lenr];
            System.arraycopy(data, 0, head, 0, hlen);
            System.arraycopy(data, hlen, decdata, 0, bodylen);
            byte[] encdata = DES3.des3Packet(decdata, tdk.getBytes());
            send = new byte[hlen + encdata.length];
            System.arraycopy(head, 0, send, 0, hlen);
            System.arraycopy(encdata, 0, send, hlen, encdata.length);

        }else if ("3".equals(encflag)) {
            String tdk = Constants.YANTAI_TDKKEY;
            byte[] tdkey = HexT.hexstr2ByteArr(tdk);
            byte[] h7 = new byte[4];
            System.arraycopy(data, 28, h7, 0, 4);
            int orilen = Integer.parseInt(new String(h7));
            int enclen = data.length - Constants.ATMP_HEADER_LENGTH;
            byte[] head = new byte[Constants.ATMP_HEADER_LENGTH];
            byte[] encdata = new byte[enclen];
            System.arraycopy(data, 0, head, 0, Constants.ATMP_HEADER_LENGTH);
            System.arraycopy(data, Constants.ATMP_HEADER_LENGTH, encdata, 0, enclen);
            byte[] decdata = SMS4.unsms4Packet(encdata, tdkey);

            send = new byte[Constants.ATMP_HEADER_LENGTH + orilen];
            System.arraycopy(head, 0, send, 0, Constants.ATMP_HEADER_LENGTH);
            System.arraycopy(decdata, 0, send, Constants.ATMP_HEADER_LENGTH, orilen);
        } else {
            send = data;
        }

        CommAdapter adapter = new CommAdapter(Constants.IP, 3551);
        adapter.setHeadlen(4); // ����ͷ��4�ֽ�
        byte[] recv = adapter.doComm(send);

        byte[] recv2 = null;
        byte[] b = new byte[1];
        System.arraycopy(recv, 11, b, 0, 1);
        String rspenc = new String(b);
        Logger.e("Ӧ���ļ��ܱ�־:[{}]" + rspenc);
        if ("1".equals(rspenc)) {
            String tdk = Constants.YANTAI_TDKKEY;
            byte[] h7 = new byte[4];
            System.arraycopy(recv, 28, h7, 0, 4);
            int orilen = Integer.parseInt(new String(h7));
            int enclen = recv.length - Constants.ATMP_HEADER_LENGTH;
            byte[] head = new byte[Constants.ATMP_HEADER_LENGTH];
            byte[] encdata = new byte[enclen];
            System.arraycopy(recv, 0, head, 0, Constants.ATMP_HEADER_LENGTH);
            System.arraycopy(recv, Constants.ATMP_HEADER_LENGTH, encdata, 0, enclen);
            byte[] decdata = DES3.undes3Packet(encdata, tdk.getBytes());

            recv2 = new byte[Constants.ATMP_HEADER_LENGTH + orilen];
            System.arraycopy(head, 0, recv2, 0, Constants.ATMP_HEADER_LENGTH);
            System.arraycopy(decdata, 0, recv2, Constants.ATMP_HEADER_LENGTH, orilen);
        } else {
            recv2 = recv;
        }

        IsoMessage rsp = null;
        MessageFactory<IsoMessage> fac = new MessageFactory<IsoMessage>();
        try {
            rsp = fac.parseMessage(recv2, 32);
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        String respcode = rsp.getStringValue(39);
        if ("00".equals(respcode)) {

            if (rsp.getField(55) != null) {
                // ARPC��֤
            }
            unpackReSpone(rsp, op_type);
//            inter.unpackReSpone(rsp);
        } else {
            Logger.e("����ʧ��:[{}]-[{}]" + respcode, rsp.getStringValue(40));
            Logger.e("����ʧ��:[{}]-[{}]" + respcode + rsp.getStringValue(40));
            final IsoMessage finalRsp = rsp;
            InquiryBusinessActivity.this.runOnUiThread(new Runnable() {
                @SuppressLint("WrongConstant")
                @Override
                public void run() {
                    Toast toast = Toast.makeText(getApplicationContext(), finalRsp.getStringValue(40), Toast.LENGTH_LONG);

                    showMyToast(toast, 5 * 1000);
                }
            });

            this.finish();
        }
    }

    public void showMyToast(final Toast toast, final int cnt) {
        final Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                toast.show();
            }
        }, 0, 3000);
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                toast.cancel();
                timer.cancel();
            }
        }, cnt);
    }

    private void unpackReSpone(IsoMessage response, String op_type) {
        if (op_type.equals("zhrz")) {
            SpUtils.getSPUtil(getApplicationContext()).putString("all_make_type", "zhrz");
//            dealingLayout.setVisibility(View.GONE);
//            querySuccessLayout.setVisibility(View.VISIBLE);
            if (make_type.equals("selectDetailType1") || make_type.equals("selectDetailType3") || make_type.equals("customDetailType")) {
                tradeWithCards(0);
            } else if (make_type.equals("zzhcx")) {
                num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                Logger.e("第一次获取" + num);
                excuteSBA(String.valueOf(num), bindNum);
                SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
            } else if (make_type.equals("dqmx")) {
                num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
                Logger.e("第一次获取" + num);
                DQMInstall(String.valueOf(num));
                SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
                Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
            } else {
                tradeWithCards(0);
            }


        } else if (op_type.equals("yecx")) {
            SpUtils.getSPUtil(getApplicationContext()).putString("all_make_type", "yecx");
            String f54 = response.getStringValue(54);
            final String ky_yus = f54.substring(f54.length() - 12, f54.length()).replaceFirst("^0+", "");
            if (ky_yus.equals("")) {
                accountBalance.setText("0.00");
                usableBalance.setText("0.00");
            } else {

                kyye = ky_yus.substring(ky_yus.length() - 2);
                Logger.e(kyye);
                final String zm_yus = f54.substring(9, 20).replaceFirst("^0+", "");
                zhye = zm_yus.substring(zm_yus.length() - 2);
                if (zm_yus.substring(0, zm_yus.length() - 2).equals("")) {
                    accountBalance.setText("0." + zhye);
                } else {
                    accountBalance.setText(zm_yus.substring(0, zm_yus.length() - 2) + "." + zhye);
                }
                if (ky_yus.substring(0, ky_yus.length() - 2).equals("")) {
                    usableBalance.setText("0." + kyye);
                } else {
                    usableBalance.setText(ky_yus.substring(0, ky_yus.length() - 2) + "." + kyye);
                }
            }


            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    ficationingLayout.setVisibility(View.GONE);
                    dealingLayout.setVisibility(View.GONE);
                    querySuccessLayout.setVisibility(View.VISIBLE);
                }
            });
        } else if (op_type.equals("hq_mxcx1") || op_type.equals("hq_mxcx3") || op_type.equals("hq_cuastomdata")) {
            SpUtils.getSPUtil(getApplicationContext()).putString("all_make_type", "hq_mxcx");
            beans = new ArrayList<>();
            if (response.getStringValue(59) == null) {
                f59 = false;
            } else {
                if (response.getStringValue(59).substring(0, 1).equals("0")) {
                    f59 = true;
                    f59data = "2" + response.getStringValue(59).substring(1, response.getStringValue(59).length());
                } else {
                    f59 = false;
                }
            }

            List<Map<String, String>> list = new ArrayList<Map<String, String>>();
            String custname = "";
            // 明细信息  后台一次最多返回25条记录
            if (response.getField(123) != null) {
                String f123 = response.getStringValue(123);

//			System.out.println("f123=["+f123+"]");
                f123 = f123 + " ";// 防止末尾没有内容导致 split 函数计算不准确
                String notes[] = f123.split("[\u007c]");
                custname = notes[0]; // 客户名称
                String snum = notes[1]; // 明细笔数
                int num = Integer.parseInt(snum);
                unpackF123(2, num, notes, list);
            }
            // 当交易明细过多时，第123域存放不完时，剩余的部分放在120域下发
            if (response.getField(120) != null) {
                String f120 = response.getStringValue(120);

//			System.out.println("f120=["+f120+"]");
                f120 = f120 + " ";// 防止末尾没有内容导致 split 函数计算不准确
                String notes[] = f120.split("[\u007c]");
                String snum = notes[0]; // 明细笔数
                int num = Integer.parseInt(snum);
                unpackF123(1, num, notes, list);

            }

            System.out.println("账户名称：" + custname + "；返回记录数：" + list.size());
            for (int i = 0; i < list.size(); i++) {
                Map<String, String> data = list.get(i);
                System.out.println("第" + i + "条交易信息=" + data);
            }

        } else if (op_type.equals("llcx")) {
            SpUtils.getSPUtil(getApplicationContext()).putString("all_make_type", "llcx");
            final List<InTrates_Bean> inTrates_beans = new ArrayList<>();
            String f123 = response.getStringValue(123);
            String data[] = f123.split("\\|");
            int n = 1;
            for (int i = 0; i < data.length / 2; i++) {

                InTrates_Bean inTrates_bean = new InTrates_Bean(data[n], data[n + 1]);
                inTrates_beans.add(inTrates_bean);
                n = n + 2;

            }
            Logger.e(inTrates_beans.size() + "");
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
                    interestRatesRecyclerview.setLayoutManager(linearLayoutManager);
                    InTrates_adapter inTrates_adapter = new InTrates_adapter(R.layout.interes_trates_layout_item, inTrates_beans);
                    interestRatesRecyclerview.setAdapter(inTrates_adapter);

                }
            });

        } else if (op_type.equals("zzhcx")) {
            SpUtils.getSPUtil(getApplicationContext()).putString("all_make_type", "zzhcx");
            beans_zzh = new ArrayList<>();
            if (response.getStringValue(59) == null) {
                f59_zzhcx = false;
            } else {
                if (response.getStringValue(59).substring(0, 1).equals("0")) {
                    f59_zzhcx = true;
                    f59data_zzhcx = "2" + response.getStringValue(59).substring(1, response.getStringValue(59).length());
                } else {
                    f59_zzhcx = false;
                }
            }

            //子账户查询

            List<Map<String, String>> list = new ArrayList<Map<String, String>>();
            // 子账户信息
            if (response.getField(123) != null) {
                String f123 = response.getStringValue(123);

//			System.out.println("f123=["+f123+"]");
                f123 = f123 + " ";// 防止末尾没有内容导致 split 函数计算不准确
                String notes[] = f123.split("[\u007c]");

                String custname = notes[0]; // 客户名称
                String signflag = notes[1]; // 签约标志
                String prodname = notes[2]; // 理财产品名称
                String snum = notes[3]; // 明细笔数
                int num = Integer.parseInt(snum);
                String name = custname;
                System.out.println("客户名称=[" + custname + "]");
                System.out.println("签约标志=[" + signflag + "]");
                System.out.println("理财产品名称=[" + prodname + "]");
//			System.out.println("snum=["+snum+"]");

                unpackF123ZXH(4, num, notes, list);

            }
            // 当客户子账户过多时，第123域存放不完时，剩余的部分放在120域下发
            if (response.getField(120) != null) {
                String f120 = response.getStringValue(120);

//			System.out.println("f120=["+f120+"]");
                f120 = f120 + " ";// 防止末尾没有内容导致 split 函数计算不准确
                String notes[] = f120.split("[\u007c]");
                String snum = notes[0]; // 明细笔数
                int num = Integer.parseInt(snum);
                unpackF123ZXH(1, num, notes, list);

            }

//		System.out.println("list="+list);
            for (int i = 0; i < list.size(); i++) {
                Map<String, String> data = list.get(i);
                System.out.println("第" + i + "个子账户信息=" + data);
            }

        } else if (op_type.equals("dqmx")) {
            SpUtils.getSPUtil(getApplicationContext()).putString("all_make_type", "dqmx");
            Logger.e("dqmx");
            //定期明细查询
            beans_dq = new ArrayList<>();
            if (response.getStringValue(59) == null) {
                f59_dq = false;
            } else {
                if (response.getStringValue(59).substring(0, 1).equals("0")) {
                    f59_dq = true;
                    f59_dqdata = "2" + response.getStringValue(59).substring(1, response.getStringValue(59).length());
                } else {
                    f59_dq = false;
                }
            }

            List<Map<String, String>> list = new ArrayList<Map<String, String>>();
            String custname = "";
            // 明细信息  后台一次最多返回25条记录
            if (response.getField(123) != null) {
                String f123 = response.getStringValue(123);

//			System.out.println("f123=["+f123+"]");
                f123 = f123 + " ";// 防止末尾没有内容导致 split 函数计算不准确
                String notes[] = f123.split("[\u007c]");
                custname = notes[0]; // 客户名称
                String snum = notes[1]; // 明细笔数
                int num = Integer.parseInt(snum);
                unpackDQMXF123(2, num, notes, list);
            }
            // 当交易明细过多时，第123域存放不完时，剩余的部分放在120域下发
            if (response.getField(120) != null) {
                String f120 = response.getStringValue(120);

//			System.out.println("f120=["+f120+"]");
                f120 = f120 + " ";// 防止末尾没有内容导致 split 函数计算不准确
                String notes[] = f120.split("[\u007c]");
                String snum = notes[0]; // 明细笔数
                int num = Integer.parseInt(snum);
                unpackDQMXF123(1, num, notes, list);
            }
        }
    }

    /**
     * 定期明细
     *
     * @param start 从第几个子域开始为记录内容
     * @param num   记录条数
     * @param notes 拆包子域集合
     * @param list  返回的拆包结果
     */
    private void unpackDQMXF123(int start, int num, String notes[], List<Map<String, String>> list) {

        // 每一条明细记录有11个子域
        int nrecod = 11;
//		System.out.println("lengh1="+notes.length);

        if (dqqq_num != 0) {

            for (int i = 0; i < num; i++) {

//            Map<String, String> data = new HashMap<String, String>();
                String note1 = notes[start + i * nrecod + 0];
                String note2 = notes[start + i * nrecod + 1];
                String note3 = notes[start + i * nrecod + 2];
                String note4 = notes[start + i * nrecod + 3];
                String note5 = notes[start + i * nrecod + 4];
                String note6 = notes[start + i * nrecod + 5];
                String note7 = notes[start + i * nrecod + 6];
                String note8 = notes[start + i * nrecod + 7];
                String note9 = notes[start + i * nrecod + 8];
                String note10 = notes[start + i * nrecod + 9];
                String note11 = notes[start + i * nrecod + 10];

//                Mx_Bean bean = new Mx_Bean(note2, note1, note11, note6, note3, "", toacct, toactna);
                DQ_Bean dq_bean = new DQ_Bean(note1, note2, note3, note5, note6, note7, note10);
                beans_dq.add(dq_bean);


                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        dq_adapter.addData(beans_dq);
//                    adapter_mx.notifyDataSetChanged();
                    }
                });
            }
        } else {
            for (int i = 0; i < num; i++) {

//            Map<String, String> data = new HashMap<String, String>();
                String note1 = notes[start + i * nrecod + 0];
                String note2 = notes[start + i * nrecod + 1];
                String note3 = notes[start + i * nrecod + 2];
                String note4 = notes[start + i * nrecod + 3];
                String note5 = notes[start + i * nrecod + 4];
                String note6 = notes[start + i * nrecod + 5];
                String note7 = notes[start + i * nrecod + 6];
                String note8 = notes[start + i * nrecod + 7];
                String note9 = notes[start + i * nrecod + 8];
                String note10 = notes[start + i * nrecod + 9];
                String note11 = notes[start + i * nrecod + 10];
                String time = note5.substring(2);
                if (note10.replaceAll("^(0+)", "") == "") {


//                Mx_Bean bean = new Mx_Bean(note2, note1, note11, note6, note3, "", toacct, toactna);
                    DQ_Bean
                            dq_bean = new DQ_Bean(note1, note2, note3, time, note6, note7, "0%");
                    beans_dq.add(dq_bean);
                } else {

                    String lv = note10.replaceAll("^(0+)", "");
                    String lv_s = lv.substring(0, 1);
                    String lv_end = lv.substring(lv.length() - 5);
//                Mx_Bean bean = new Mx_Bean(note2, note1, note11, note6, note3, "", toacct, toactna);
                    DQ_Bean
                            dq_bean = new DQ_Bean(note1, note2, note3, time, note6, note7, lv_s + "." + lv_end + "%");
                    beans_dq.add(dq_bean);
                }


            }
        }
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (dqqq_num == 0) {

                    initdqrecycler(beans_dq);
                    ficationingLayout.setVisibility(View.GONE);
                    homeQueryLayout.setVisibility(View.GONE);
                    detailQueryTitle.setText("活期存款账户交易明细");

                    detailQueryLayout.setVisibility(View.VISIBLE);
                }

            }
        });
    }

    private void initdqrecycler(List<DQ_Bean> beans_dq) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
        detailQueryRecyclerview.setLayoutManager(linearLayoutManager);
        dq_adapter = new Dq_adapter(R.layout.dq_item_layout, beans_dq);
        detailQueryRecyclerview.setAdapter(dq_adapter);
        dq_adapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
            @Override
            public void onLoadMoreRequested() {
                detailQueryRecyclerview.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        /**
                         *  Alltotal是总条数，每次上拉加载10条数据
                         *  每次上拉total可以+10
                         *  Alltotal>total
                         *  可以继续上拉加载
                         *  <=表示数据已经加载完毕
                         */

                        if (f59_dq) {
                            dq_adapter.loadMoreComplete();
                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    setOnLoadDQMoreData();
                                }
                            }).start();


                        } else {
                            dq_adapter.loadMoreEnd();
                        }
                    }
                }, 3000);
            }
        });
    }

    private void setOnLoadDQMoreData() {
        dqqq_num = dqqq_num + 1;
        num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
        Logger.e("第一次获取" + num);
        DQMInstall(String.valueOf(num));
        SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
        Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
    }

    /**
     * @param start 从第几个子域开始为记录内容
     * @param num   记录条数
     * @param notes 拆包子域集合
     * @param list  返回的拆包结果
     */
    private void unpackF123(int start, int num, String notes[], List<Map<String, String>> list) {

        // 每一条明细记录有9个子域
        int nrecod = 9;
//		System.out.println("lengh1="+notes.length);

        if (qingqiu_num != 0) {

            for (int i = 0; i < num; i++) {

//            Map<String, String> data = new HashMap<String, String>();
                String trandt = notes[start + i * nrecod + 0]; // 交易日期
                String channel = notes[start + i * nrecod + 1]; // 交易渠道
                String zycode = notes[start + i * nrecod + 2]; // 摘要代码
                String tranam = notes[start + i * nrecod + 3];
                String money;
                if (tranam.length() == 2) {
                    money = "0" + "." + tranam;
                } else if (tranam.length() == 1) {
                    money = "0.0" + tranam;
                } else {
                    String money_end = tranam.substring(tranam.length() - 2, tranam.length());

                    String money_start = tranam.substring(0, tranam.length() - 2);
                    money = money_start + "." + money_end;
                }
                String balance = notes[start + i * nrecod + 4]; // 账户余额
                String ye = balance.substring(0, balance.length() - 2) + "." + balance.substring(balance.length() - 2);

                String brchno = notes[start + i * nrecod + 5]; // 交易机构
                String toacct = notes[start + i * nrecod + 6]; // 对方账号
                String toactna = notes[start + i * nrecod + 7]; // 对方户名
                String cdflg = notes[start + i * nrecod + 8]; // 借贷别
                cdflg = cdflg.trim();

                Mx_Bean bean = new Mx_Bean(money, trandt, channel, zycode, ye, brchno, toacct, toactna);
                beans.add(bean);
                Logger.e(beans.size() + "beans.size");
            }
//            adapter_mx.notifyDataSetChanged();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    adapter_mx.addData(beans);
//                    adapter_mx.notifyDataSetChanged();
                }
            });
        } else {
            for (int i = 0; i < num; i++) {

//            Map<String, String> data = new HashMap<String, String>();
                String trandt = notes[start + i * nrecod + 0]; // 交易日期
                String channel = notes[start + i * nrecod + 1]; // 交易渠道
                String zycode = notes[start + i * nrecod + 2]; // 摘要代码
//                String tranam = notes[start + i * nrecod + 3].substring(0, notes[start + i * nrecod + 3].length() - 2) + "." + notes[start + i * nrecod + 3].substring(notes[start + i * nrecod + 3].length() - 2, notes[start + i * nrecod + 3].length()); // 交易金额
//                String tranam = "";
                String tranam = notes[start + i * nrecod + 3]; // 交易金额
                String money;
                if (tranam.length() == 2) {
                    money = "0" + "." + tranam;
                } else if (tranam.length() == 1) {
                    money = "0.0" + tranam;
                } else {
                    String money_end = tranam.substring(tranam.length() - 2, tranam.length());

                    String money_start = tranam.substring(0, tranam.length() - 2);
                    money = money_start + "." + money_end;
                }
                String balance = notes[start + i * nrecod + 4]; // 账户余额
                String ye = balance.substring(0, balance.length() - 2) + "." + balance.substring(balance.length() - 2);
                String brchno = notes[start + i * nrecod + 5]; // 交易机构
                String toacct = notes[start + i * nrecod + 6]; // 对方账号
                String toactna = notes[start + i * nrecod + 7]; // 对方户名
                String cdflg = notes[start + i * nrecod + 8]; // 借贷别
                cdflg = cdflg.trim();
                Mx_Bean bean = new Mx_Bean(money, trandt, channel, zycode, ye, brchno, toacct, toactna);
                beans.add(bean);

            }
        }


        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (qingqiu_num == 0) {
                    Logger.e("ccccccccccccccccccc");
                    initmxrecycler(beans);
                    ficationingLayout.setVisibility(View.GONE);
                    homeQueryLayout.setVisibility(View.GONE);
                    detailQueryTitle.setText("活期存款账户交易明细");

                    detailQueryLayout.setVisibility(View.VISIBLE);
                }

            }
        });

    }

    private void initmxrecycler(List<Mx_Bean> beans) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
        detailQueryRecyclerview.setLayoutManager(linearLayoutManager);
        adapter_mx = new Mx_adapter(R.layout.mx_item_layout, beans);
        detailQueryRecyclerview.setAdapter(adapter_mx);
        adapter_mx.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
            @Override
            public void onLoadMoreRequested() {
                detailQueryRecyclerview.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        /**
                         *  Alltotal是总条数，每次上拉加载10条数据
                         *  每次上拉total可以+10
                         *  Alltotal>total
                         *  可以继续上拉加载
                         *  <=表示数据已经加载完毕
                         */

                        if (f59) {
                            adapter_mx.loadMoreComplete();
                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    setOnLoadwuliuMoreData();
                                }
                            }).start();


                        } else {
                            adapter_mx.loadMoreEnd();
                        }
                    }
                }, 3000);
            }
        });
    }

    private void setOnLoadwuliuMoreData() {
        qingqiu_num = qingqiu_num + 1;
        if (make_type.equals("selectDetailType1")) {
            num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
            Logger.e("第一次获取" + num);
            excuteQMX(String.valueOf(num), bindNum, track2Data);
            SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
            Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
        } else if (make_type.equals("selectDetailType3")) {
            num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
            Logger.e("第一次获取" + num);
            excuteQMX3(String.valueOf(num), bindNum, track2Data);
            SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
            Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
        } else if (make_type.equals("customDetailType")) {
            num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
            Logger.e("第一次获取" + num);
            excuteQMXcustom(String.valueOf(num), bindNum, track2Data);
            SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
            Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
        }
    }


    /**
     * 子账户查询
     *
     * @param start 从第几个子域开始为记录内容
     * @param num   记录条数
     * @param notes 拆包子域集合
     * @param list  返回的拆包结果
     */
    private void unpackF123ZXH(int start, int num, String notes[], List<Map<String, String>> list) {

        // 每一条明细记录有17个子域
        int nrecod = 17;
        Logger.e("lengh1=" + notes.length);
        if (qqzzhcx_num != 0) {
            for (int i = 0; i < num; i++) {
                Map<String, String> data = new HashMap<String, String>();
                String prdcode = notes[start + i * nrecod + 0]; // 产品代码
                Logger.e("prdcode=" + prdcode);
                // 产品名称
                String pdpname = notes[start + i * nrecod + 1];
                Logger.e("pdpname=" + pdpname);
                String pdpcode = notes[start + i * nrecod + 2]; // 账户编号
                String f122_3 = pdpcode;
                Logger.e("pdpcode=" + pdpcode);
                // 理财帐户笔号
                String seqno = notes[start + i * nrecod + 3];
                String f122_4 = seqno;
                Logger.e("seqno=" + seqno);
                String acctsts = notes[start + i * nrecod + 4]; // 帐户状态
                Logger.e("acctsts=" + acctsts);
                // 帐户余额
                String opacamt = notes[start + i * nrecod + 5];
                Logger.e("opacamt=" + opacamt);
                String acctbal = notes[start + i * nrecod + 6]; // 可用余额
                Logger.e("acctbal=" + acctbal);
                // 起息日期
                String valdt = notes[start + i * nrecod + 7];
                Logger.e("valdt=" + valdt);
                // 存期
                String depprd = notes[start + i * nrecod + 8];
                Logger.e("depprd=" + depprd);
                // 到期日期
                String duedt = notes[start + i * nrecod + 9];
                Logger.e("duedt=" + duedt);
                String mngflg = notes[start + i * nrecod + 10]; // 自动转存标志
                Logger.e("mngflg=" + mngflg);
                String prdsdep = notes[start + i * nrecod + 11]; // 约定存期
                Logger.e("prdsdep=" + prdsdep);
                // 利率
                String trndintc = notes[start + i * nrecod + 12];
                Logger.e("trndintc=" + trndintc);
                String drwdt = notes[start + i * nrecod + 13]; // 通知支取日期
                Logger.e("drwdt=" + drwdt);
                String drwdsgn = notes[start + i * nrecod + 14]; // 通知支取设定
                Logger.e("drwdsgn=" + drwdsgn);
                String drwamt = notes[start + i * nrecod + 15]; // 通知支取金额
                Logger.e("drwamt=" + drwamt);
                String curiden = notes[start + i * nrecod + 16]; // 钞汇鉴别
                curiden = curiden.trim();
                Logger.e("curiden=" + curiden);
                Logger.e(trndintc + "trndintc");
                String lv_first = trndintc.substring(2, 3);
                String lv_ed = trndintc.substring(3, trndintc.length());
                String lv = lv_first + "." + lv_ed + "%";
                int monl = opacamt.replaceFirst("^0+", "").length();
                String money = opacamt.replaceFirst("^0+", "").substring(0, monl - 2);
                Logger.e(money + "money");
                Select_subaccount_Bean bean = new
                        Select_subaccount_Bean(pdpname, pdpcode, seqno, money, valdt, duedt, lv, pdpname.substring(0, 3), lv);
                beans_zzh.add(bean);
            }
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    adapter_zzhcx.addData(beans_zzh);
//                    adapter_mx.notifyDataSetChanged();
                }
            });
        } else {
            for (int i = 0; i < num; i++) {
                Map<String, String> data = new HashMap<String, String>();
                String prdcode = notes[start + i * nrecod + 0]; // 产品代码
                Logger.e("prdcode=" + prdcode);
                // 产品名称
                String pdpname = notes[start + i * nrecod + 1];
                Logger.e("pdpname=" + pdpname);
                String pdpcode = notes[start + i * nrecod + 2]; // 账户编号
                String f122_3 = pdpcode;
                Logger.e("pdpcode=" + pdpcode);
                // 理财帐户笔号
                String seqno = notes[start + i * nrecod + 3];
                String f122_4 = seqno;
                Logger.e("seqno=" + seqno);
                String acctsts = notes[start + i * nrecod + 4]; // 帐户状态
                Logger.e("acctsts=" + acctsts);
                // 帐户余额
                String opacamt = notes[start + i * nrecod + 5];
                Logger.e("opacamt=" + opacamt);
                String acctbal = notes[start + i * nrecod + 6]; // 可用余额
                Logger.e("acctbal=" + acctbal);
                // 起息日期
                String valdt = notes[start + i * nrecod + 7];
                Logger.e("valdt=" + valdt);
                // 存期
                String depprd = notes[start + i * nrecod + 8];
                Logger.e("depprd=" + depprd);
                // 到期日期
                String duedt = notes[start + i * nrecod + 9];
                Logger.e("duedt=" + duedt);
                String mngflg = notes[start + i * nrecod + 10]; // 自动转存标志
                Logger.e("mngflg=" + mngflg);
                String prdsdep = notes[start + i * nrecod + 11]; // 约定存期
                Logger.e("prdsdep=" + prdsdep);
                // 利率
                String trndintc = notes[start + i * nrecod + 12];
                Logger.e("trndintc=" + trndintc);
                String drwdt = notes[start + i * nrecod + 13]; // 通知支取日期
                Logger.e("drwdt=" + drwdt);
                String drwdsgn = notes[start + i * nrecod + 14]; // 通知支取设定
                Logger.e("drwdsgn=" + drwdsgn);
                String drwamt = notes[start + i * nrecod + 15]; // 通知支取金额
                Logger.e("drwamt=" + drwamt);
                String curiden = notes[start + i * nrecod + 16]; // 钞汇鉴别
                curiden = curiden.trim();
                Logger.e("curiden=" + curiden);
                Logger.e(trndintc + "trndintc");
                String lv_first = trndintc.substring(2, 3);
                String lv_ed = trndintc.substring(3, trndintc.length());
                String lv = lv_first + "." + lv_ed + "%";
                String money = "";
                if (opacamt.equals("000000000000000")) {
                    money = "0.00";
                } else {
                    int monl = opacamt.replaceFirst("^0+", "").length();
                    Logger.e(monl + "");
                    money = opacamt.replaceFirst("^0+", "").substring(0, monl - 2);
                }

                Logger.e(money + "money");
                Select_subaccount_Bean bean = new
                        Select_subaccount_Bean(pdpname, pdpcode, seqno, money, valdt, duedt, lv, pdpname.substring(0, 3), lv);
                beans_zzh.add(bean);
            }
        }

        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                if (qqzzhcx_num == 0) {
                    initzzhcxecycler(beans_zzh);
                    ficationingLayout.setVisibility(View.GONE);
                    homeQueryLayout.setVisibility(View.GONE);
                    detailQueryTitle.setText("aaaaa");
                    querySunLayout.setVisibility(View.VISIBLE);
                    querySunOkbtn.setVisibility(View.GONE);
                }

            }
        });

    }

    /**
     * 初始化子账户查询recyclerview
     *
     * @param beans
     */
    private void initzzhcxecycler(List<Select_subaccount_Bean> beans) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
        querySunRecyclerview.setLayoutManager(linearLayoutManager);
        adapter_zzhcx = new Select_subaccount_adapter(R.layout.select_subaccount_adapter_item_layout, beans, "子账户");
        querySunRecyclerview.setAdapter(adapter_zzhcx);
        adapter_zzhcx.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
            @Override
            public void onLoadMoreRequested() {
                querySunRecyclerview.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        /**
                         *  Alltotal是总条数，每次上拉加载10条数据
                         *  每次上拉total可以+10
                         *  Alltotal>total
                         *  可以继续上拉加载
                         *  <=表示数据已经加载完毕
                         */

                        if (f59_zzhcx) {
                            adapter_zzhcx.loadMoreComplete();
                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    setOnLoadzzhcxMoreData();
                                }
                            }).start();


                        } else {
                            adapter_zzhcx.loadMoreEnd();
                        }
                    }
                }, 3000);
            }
        });
    }

    private void setOnLoadzzhcxMoreData() {
        qqzzhcx_num = qqzzhcx_num + 1;
        num = SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 0);
        Logger.e("第一次获取" + num);
        excuteSBA(String.valueOf(num), bindNum);
        SpUtils.getSPUtil(getApplicationContext()).putInt("s_Num", num + 1);
        Logger.e("第二次获取" + SpUtils.getSPUtil(getApplicationContext()).getInt("s_Num", 1000));
    }


}
